<?php namespace Controller;
	
	class Carpetas extends Controller {
		
		function __construct() {
			$this->models = array("Carpetas", "Clientes", "Log_Entrys");
			$this->_loadModels();
		}
		
		public function consultaGlobal() {
			return $this;
		}
		
		public function buscarClienteAjax() {
			if(!empty($this->params[2])) {
				$this->_set('cliente', $this->models["Clientes"]->findById($this->params[2]));
				return $this;
			} elseif (!empty($this->params[1])) {
				$this->_set('cliente', $this->models["Clientes"]->findByDocumento($this->params[1]));
				return $this;
			} elseif (!empty($this->params[0])) {
				$this->_set('cliente', $this->models["Clientes"]->findByNombre(mb_strtoupper($this->params[0])));
				return $this; 
			} 
			return $this;
		}
		
		public function buscarCarpetasPorClienteAjax() {
			$this->_set('carpetas', $this->models["Carpetas"]->findByCliente_id($this->params[0], array("empresas","operatorias","cobradores")));
			return $this;
		}
		
		public function buscarLogEntrysPorClienteAjax() {
			$this->_set('logs', $this->models["Log_Entrys"]->findByCliente_id($this->params[0]));
			return $this;
		}

	}